In NASM labels next to each other in memory are causing printing issues

十年热恋 提交于 2019-11-27 02:24:26

Your computation of hlen includes the string Goodbye! because it comes after the defintion of GOODBYE_MSG. The expression $ - HELLO_MSG is the number of bytes between the label HELLO_MSG and the line where hlen is defined. That is why your first call to print_string prints both messages.

Try this order instead:

HELLO_MSG db 'Hello, World!',0
hlen equ $ - HELLO_MSG

GOODBYE_MSG db 'Goodbye!',0
glen equ $ - GOODBYE_MSG
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!