两个整数的NASM打印产品

发布于 2025-02-06 18:36:41 字数 546 浏览 1 评论 0原文

我正在尝试乘以两个整数,然后将它们转换为ASCII然后打印。代码编译罚款,没有任何错误,但在屏幕上没有显示任何内容。

section .text

global _start

_start:
    ;to print a number after multiplication
    mov eax, x
    mov ebx, y
    MUL ebx

    ADD eax, '0' ;convert product to ascii
    mov [mynum], eax
    
    mov     ecx, mynum
    mov     edx, 1
    mov     ebx, 1
    mov     eax, 4
    int     0x80
    
    mov eax, 1
    mov ebx, 0
    int 0x80

section .data
    x dd 2
    y dd 3

segment .bss
    mynum resd 1

谢谢您的帮助!

编辑:当我在第10行上删除中断时,现在将零打印到终端

I am trying to multiply two integers and then converting them to ascii and then printing. The code compiles fine and no errors are given but nothing shows on screen.

section .text

global _start

_start:
    ;to print a number after multiplication
    mov eax, x
    mov ebx, y
    MUL ebx

    ADD eax, '0' ;convert product to ascii
    mov [mynum], eax
    
    mov     ecx, mynum
    mov     edx, 1
    mov     ebx, 1
    mov     eax, 4
    int     0x80
    
    mov eax, 1
    mov ebx, 0
    int 0x80

section .data
    x dd 2
    y dd 3

segment .bss
    mynum resd 1

Thank you for helping!

EDIT: When I remove the interrupt on line 10, a zero is now printed to the terminal

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文